import request from "@/utils/request";

//登录
export function login(params = {}) {
    return request({
        method: "post",
        url: '/user/login',
        data: params
    })
}

//注册
export function register(params = {}) {
    return request({
        method: "post",
        url: '/user/register',
        data: params
    })
}

//工具电话号码获取用户
export function getUserByPhone(phone = {}) {
    return request({
        method: "get",
        url: '/user/getUserByPhone',
        params: {
            phone: phone
        }
    })
}

//更新用户
export function updateUser(params = {}) {
    return request({
        method: "post",
        url: '/user/updateUser',
        params: params
    })
}

//修改密码
export function updateUserPassword(params = {}) {
    return request({
        method: "post",
        url: '/user/updateUserPassword',
        params: params
    })
}

//修改手机号码
export function updateUserPhone(params = {}) {
    return request({
        method: "post",
        url: '/user/updateUserPhone',
        params: params
    })
}

//获取用户
export function getUser(page, size, name) {
    return request({
        method: "get",
        url: '/user/getUser',
        params: {
            page: page,
            size: size,
            name: name
        }
    })
}

//邮箱验证
export function emailCode(user, email, isReset) {
    return request({
        method: "post",
        url: '/user/emailCode',
        params: {
            user: user,
            email: email,
            isReset: isReset
        }
    })
}

//更换邮箱
export function updateEmail(user, email, code, isRest) {
    return request({
        method: "post",
        url: '/user/updateEmail',
        params: {
            user: user,
            email: email,
            code: code,
            isRest: isRest
        }
    })
}

//重置密码
export function restPassword(user, password) {
    return request({
        method: "post",
        url: '/user/restPassword',
        params: {
            user: user,
            password: password
        }
    })
}

export default {
    getUser,
    login,
    register,
    getUserByPhone,
    updateUser,
    updateUserPhone,
    updateUserPassword,
    emailCode,
    updateEmail,
    restPassword
}